package com.minimalist.common.entity.basic.po;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import com.minimalist.common.config.mybatis.InsertFullColumnHandler;
import com.minimalist.common.config.mybatis.UpdateFullColumnHandler;
import com.minimalist.common.config.mybatis.bo.BaseEntity;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

/**
 * 部门表 实体类。
 *
 * @author 小太阳
 * @since 2024-10-18
 */
@Table(value = "m_dept", onInsert = InsertFullColumnHandler.class, onUpdate = UpdateFullColumnHandler.class)
public class MDept extends BaseEntity implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 部门id
     */
    private Long deptId;

    /**
     * 父部门id
     */
    private Long parentDeptId;

    /**
     * 祖级列表
     */
    private String ancestors;

    /**
     * 部门名称
     */
    private String deptName;

    /**
     * 部门负责人
     */
    private Long deptLeader;

    /**
     * 显示顺序
     */
    private Integer deptSort;

    /**
     * 联系电话
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 状态  0禁用 1正常
     */
    private Integer status;

    /**
     * 租户编号
     */
    @Column(tenantId = true)
    private Long tenantId;

    // 构造函数
    public MDept() {
    }

    public MDept(Long deptId, Long parentDeptId, String ancestors, String deptName, Long deptLeader, Integer deptSort, String phone, String email, Integer status, Long tenantId) {
        this.deptId = deptId;
        this.parentDeptId = parentDeptId;
        this.ancestors = ancestors;
        this.deptName = deptName;
        this.deptLeader = deptLeader;
        this.deptSort = deptSort;
        this.phone = phone;
        this.email = email;
        this.status = status;
        this.tenantId = tenantId;
    }

    // Getter和Setter方法
    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public Long getParentDeptId() {
        return parentDeptId;
    }

    public void setParentDeptId(Long parentDeptId) {
        this.parentDeptId = parentDeptId;
    }

    public String getAncestors() {
        return ancestors;
    }

    public void setAncestors(String ancestors) {
        this.ancestors = ancestors;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public Long getDeptLeader() {
        return deptLeader;
    }

    public void setDeptLeader(Long deptLeader) {
        this.deptLeader = deptLeader;
    }

    public Integer getDeptSort() {
        return deptSort;
    }

    public void setDeptSort(Integer deptSort) {
        this.deptSort = deptSort;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    // Builder模式
    public static MDeptBuilder builder() {
        return new MDeptBuilder();
    }

    public static class MDeptBuilder {
        private Long deptId;
        private Long parentDeptId;
        private String ancestors;
        private String deptName;
        private Long deptLeader;
        private Integer deptSort;
        private String phone;
        private String email;
        private Integer status;
        private Long tenantId;

        public MDeptBuilder deptId(Long deptId) {
            this.deptId = deptId;
            return this;
        }

        public MDeptBuilder parentDeptId(Long parentDeptId) {
            this.parentDeptId = parentDeptId;
            return this;
        }

        public MDeptBuilder ancestors(String ancestors) {
            this.ancestors = ancestors;
            return this;
        }

        public MDeptBuilder deptName(String deptName) {
            this.deptName = deptName;
            return this;
        }

        public MDeptBuilder deptLeader(Long deptLeader) {
            this.deptLeader = deptLeader;
            return this;
        }

        public MDeptBuilder deptSort(Integer deptSort) {
            this.deptSort = deptSort;
            return this;
        }

        public MDeptBuilder phone(String phone) {
            this.phone = phone;
            return this;
        }

        public MDeptBuilder email(String email) {
            this.email = email;
            return this;
        }

        public MDeptBuilder status(Integer status) {
            this.status = status;
            return this;
        }

        public MDeptBuilder tenantId(Long tenantId) {
            this.tenantId = tenantId;
            return this;
        }

        public MDept build() {
            return new MDept(deptId, parentDeptId, ancestors, deptName, deptLeader, deptSort, phone, email, status, tenantId);
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        MDept mDept = (MDept) o;
        return Objects.equals(deptId, mDept.deptId) &&
                Objects.equals(parentDeptId, mDept.parentDeptId) &&
                Objects.equals(ancestors, mDept.ancestors) &&
                Objects.equals(deptName, mDept.deptName) &&
                Objects.equals(deptLeader, mDept.deptLeader) &&
                Objects.equals(deptSort, mDept.deptSort) &&
                Objects.equals(phone, mDept.phone) &&
                Objects.equals(email, mDept.email) &&
                Objects.equals(status, mDept.status) &&
                Objects.equals(tenantId, mDept.tenantId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), deptId, parentDeptId, ancestors, deptName, deptLeader, deptSort, phone, email, status, tenantId);
    }

    @Override
    public String toString() {
        return "MDept{" +
                "deptId=" + deptId +
                ", parentDeptId=" + parentDeptId +
                ", ancestors='" + ancestors + '\'' +
                ", deptName='" + deptName + '\'' +
                ", deptLeader=" + deptLeader +
                ", deptSort=" + deptSort +
                ", phone='" + phone + '\'' +
                ", email='" + email + '\'' +
                ", status=" + status +
                ", tenantId=" + tenantId +
                '}';
    }
}
